<template>
  <div style="height: 100%; width: 100%; position: relative">
      <div class="pagetop" ref="buttondiv">
          <template>
              <table style="width: 100%">
                  <tr>
                      <td align="right" width="60px">质控日期</td>
                      <td>
                          <el-date-picker v-model="qcdate1" type="date" placeholder="开始日期" value-format="yyyy-MM-dd" style="width: 130px"></el-date-picker>
                      </td>
                      <td width="30px" style="text-align: center">至</td>
                      <td>
                          <el-date-picker v-model="qcdate2" type="date" placeholder="结束日期" value-format="yyyy-MM-dd" style="width: 130px"></el-date-picker>
                      </td>
                      <td align="right" width="60px">仪器</td>
                      <td>
                          <rm-ddl-instrument @change="labinstrumentchange" width="220px" v-model="instrId" defaultflag="1" prgno="LIS521" :clearable="true"></rm-ddl-instrument>
                      </td>
                      <td align="right" width="40px">累计</td>
                      <td>
                          <el-select v-model="inuse">
                              <el-option v-for="item in inuseOption" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</el-option>
                          </el-select>
                      </td>
                      <td align="right" width="30px">画图</td>
                      <td>
                          <el-select v-model="draw">
                              <el-option v-for="item in drawOption" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</el-option>
                          </el-select>
                      </td>
                      <td align="right" width="60px">仪器多选</td>
                      <td>
                          <rm-ddl-instrument :multiple_choice="true" :beforeChange="beforinstridChange" @change="instridlistchange" width="220px" v-model="instridlist" defaultflag="0" prgno="LIS521" :clearable="true"></rm-ddl-instrument>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">批号</td>
                      <td>
                          <el-input v-model="batchno" id="batchno" style="width: 130px"></el-input>
                      </td>
                      <td align="right">水平</td>
                      <td>
                          <rm-ddl-common datatype="seccode" kindno="QCLEVEL" dataname="水平" v-model="qclevel" width="130px" @change="qclevelChange"></rm-ddl-common>
                      </td>

                      <td align="right">质控项目</td>
                      <td>
                          <rm-ddl-common datatype="qcinstritem" dataname="仪器对应质控项目" v-model="qcitem" :instrid="parseInt(instrId)" width="220px" @change="qcitemChange"> </rm-ddl-common>
                      </td>

                      <td align="right">审核</td>
                      <td>
                          <el-select v-model="check">
                              <el-option v-for="item in checkOption" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</el-option>
                          </el-select>
                      </td>
                      <td align="right">失控</td>
                      <td>
                          <el-select v-model="contro">
                              <el-option v-for="item in controOption" :key="item.value" :label="item.label" :value="item.value">{{ item.label }}</el-option>
                          </el-select>
                      </td>
                      <td colspan="2">

                          <el-checkbox style="padding: 0px 10px" v-model="shownotmatch" true-label="1" false-label="0">仅显示不匹配数据</el-checkbox>
                          <el-checkbox style="padding: 0px 10px" v-model="showQcinstritem" true-label="1" false-label="0">仅查询质控项目相关数据</el-checkbox>
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align: right" colspan="12">
                          <el-button type="primary" icon="el-icon-search" @click="initialList" v-has="'PINQUERY'">查询(F8)</el-button>
                          <el-button icon="el-icon-delete-solid" @click="delDetail" v-has="'PDELETE'">删除(F3)</el-button>
                          <el-button icon="el-icon-download" @click.native="BtnExport">导出(E)</el-button>
                          <el-button icon="el-icon-download" @click.native="BtnExporttxt">导出TXT(T)</el-button>
                          <el-button icon="el-icon-close" @click="BtnExc">退出(X)</el-button>
                      </td>
                  </tr>
              </table>
          </template>
      </div>
      <div class="pagecenter">
          <div ref="xTableDiv" style="height: 99%; width: 100%">
              <vxe-table show-overflow ref="xTable1" height="auto" width="100%" :loading="loading" :select-config="{ reserve: true }" :data.sync="tableData1" border size="mini" :keyboard-config="keyConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true }" :cell-class-name="getOutcontrolClassname" :sort-config="{trigger: 'cell'}">
                  <vxe-table-column type="selection" width="40" align="center"></vxe-table-column>
                  <vxe-table-column field="instrname" title="仪器" width="120px" header-align="center" sortable> </vxe-table-column>
                  <vxe-table-column field="qcdate" title="质控日期" width="100px" align="center" :formatter="['toDateString', 'yyyy-MM-dd']" sortable> </vxe-table-column>
                  <vxe-table-column field="itemcode_en" title="英文缩写" width="100" header-align="center" sortable></vxe-table-column>
                  <vxe-table-column field="rpt_itemname" title="项目名称" width="150" header-align="center" sortable></vxe-table-column>

                  <vxe-table-column field="batchno" title="批号" width="100" header-align="center" sortable></vxe-table-column>
                  <vxe-table-column field="qclevel" title="水平" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="resultdt" title="结果时间" width="140" align="center" :formatter="['toDateString', 'yyyy-MM-dd  HH:mm:ss']"></vxe-table-column>
                  <vxe-table-column field="displayvalue" title="显示结果" width="80" header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="calculatevalue" title="计算结果" width="80" header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="calculatesd" title="计算SD" width="80" header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="cp_calculatecv" title="计算CV" width="80px" :formatter="['toFixedString', 4]" header-align="center" align="right"></vxe-table-column>
                  <vxe-table-column field="controlstatus" title="在控" width="80" align="center" :formatter="['formatSelect', controlstatusList]"></vxe-table-column>
                  <vxe-table-column field="inuseflag" title="累计" width="50" align="center" :formatter="['formatSelect', dgList]"></vxe-table-column>
                  <vxe-table-column field="drawflag" title="画图" width="50" align="center" :formatter="['formatSelect', dgList]"></vxe-table-column>
                  <vxe-table-column field="checkflag" title="审核" width="50" align="center" :formatter="['formatSelect', dgList]" sortable></vxe-table-column>
                  <vxe-table-column field="begindt" title="靶值启用日期" width="140" align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                  <vxe-table-column field="tagvalue" title="基准靶值" width="80" align="center"></vxe-table-column>
                  <vxe-table-column field="sd" title="基准SD" width="80" align="center"></vxe-table-column>
                  <vxe-table-column field="cp_outcontroltips" title="失控提示" width="150" header-align="center"></vxe-table-column>
                  <vxe-table-column field="outcontrolreason" title="失控原因" width="150" header-align="center"></vxe-table-column>
                  <vxe-table-column field="outcontroloperation" title="失控处理" width="150" header-align="center"></vxe-table-column>
                  <vxe-table-column field="outcontrolresult" title="处理结果" width="150" header-align="center"></vxe-table-column>
                  <vxe-table-column field="cp_outcontroluser" title="处理人" width="60" header-align="center"></vxe-table-column>
                  <vxe-table-column field="outcontroloperatedt" title="处理时间" width="140" align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                  <vxe-table-column field="checkdt" title="审核时间" width="140" align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                  <vxe-table-column field="cp_checkuser" title="审核人" width="60" header-align="center"></vxe-table-column>
                  <vxe-table-column v-if="!hidelastuserndt" field="lastmodifydt" title="最后修改时间" width="140" align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                  <vxe-table-column v-if="!hidelastuserndt" field="cp_lastmodifyuser" title="最后修改人" width="150" header-align="center"></vxe-table-column>
                  <vxe-table-column field="comments" title="备注" width="100" header-align="center"></vxe-table-column>
                  <vxe-table-column v-if="!hideinstrqcval" field="originalvalue" title="机器原始结果" width="100" header-align="center"></vxe-table-column>
                  <vxe-table-column field="qcvaluesign" title="结果标识" width="150" header-align="center"></vxe-table-column>
                  <vxe-table-column field="qcname" title="质控品名称" width="150" header-align="center" sortable></vxe-table-column>
                  <vxe-table-column field="qcdataid" title="质控结果ID" width="100" header-align="center"></vxe-table-column>
                  <vxe-table-column field="qcitemvalueid" title="靶值标准ID" width="100" header-align="center"></vxe-table-column>
                  <vxe-table-column field="qcid" title="质控品ID" width="100" header-align="center" sortable></vxe-table-column>
              </vxe-table>
          </div>
      </div>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils"; //引入工具类
XEUtils.mixin({
  // 自定义全局的格式化处理函数
  formatSelect(cellValue, list) {
      let item = list.find((item) => item.value == cellValue);
      return item ? item.label : "";
  },
});
export default {
  name: "LIS521",
  data() {
      return {
          loading: false,
          hideinstrqcval: false,
          hidelastuserndt: false,
          instrId: 0,
          qcdate1: "",
          qcdate2: "",
          tableData1: [],
          qcitem: "",
          batchno: "",
          qclevel: "",
          inuse: "",
          draw: "",
          check: "",
          contro: "",
          shownotmatch: "0",
          showQcinstritem: "1",
          qclevelOption: [
              { label: "全部", value: 0 },
              { label: "1", value: 1 },
              { label: "2", value: 2 },
              { label: "3", value: 3 },
              { label: "4", value: 4 },
              { label: "5", value: 5 },
              { label: "6", value: 6 },
          ],
          inuseOption: [
              { label: "全部", value: 0 },
              { label: "累计", value: 1 },
              { label: "不累计", value: 2 },
          ],
          drawOption: [
              { label: "全部", value: 0 },
              { label: "画图", value: 1 },
              { label: "不画图", value: 2 },
          ],
          checkOption: [
              { label: "全部", value: 0 },
              { label: "已审核", value: 1 },
              { label: "未审核", value: 2 },
          ],
          controOption: [
              { label: "全部", value: "" },
              { label: "在控", value: "1" },
              { label: "失控", value: "0" },
              { label: "未判定", value: "N" },
          ],
          controlstatusList: [
              { label: "失控", value: "0" },
              { label: "在控", value: "1" },
              { label: "警告", value: "3" },
              { label: "未判定", value: null },
          ],
          dgList: [
              { label: "", value: "0" },
              { label: "√", value: "1" },
          ],
          instridlist: "",
          keyConfig: {
              isArrow: true,
              isDel: true,
              isTab: true,
              isEdit: true,
              editMethod: ({ seq, row, rowIndex, column, columnIndex, cell }) => {},
          },
          instrname: "",
          instrsname: "",
          qclevelname: "",
          qcitemname: "",
      };
  },
  // watch: {
  // },
  //html加载完成之前，执行。执行顺序：父组件-子组件
  created() {
      this.initoption();
      this.qcdate1 = XEUtils.toDateString(new Date(), "yyyy-MM-dd"); //起 始结束日期
      this.qcdate2 = XEUtils.toDateString(new Date(), "yyyy-MM-dd");
      // this.initialList(); //初始化主列表
  },
  //.html加载完成后执行。执行顺序：子组件-父组件
  mounted() {},
  updated() {},
  methods: {
      //初始化数据
      resetData() {
          this.tableData1 = [];
      },
      beforinstridChange(instridlist, flag) {
          // if (flag) {
          this.instridlist = XEUtils.clone(instridlist, true);
          // }
          return true;
      },
      instridlistchange(code, name) {
          this.instridlist = code;
          this.instrsname = name;
          if (this.instrId != "") this.instrId = "";
          // this.rptunitname = name;
          // this.dialogTableVisible = false;
          if (this.multiple_choice) {
              this.$refs.rptunitInput.focus();
          }
      },
      //查询条件校验
      queryCheck() {
          let msg;
          this.instrId = this.instrId > 0 ? this.instrId : undefined;
          // msg = this.valid(this.instrId, "请选择仪器！"); //仪器校验
          // if (msg) return false;
          msg = this.valid(this.qcdate1, "开始日期 必须填写！"); //时间校验
          if (msg) return false;
          msg = this.valid(this.qcdate2, "结束日期 必须填写！");
          if (msg) return false;
          return true;
      },
      async initoption() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS5/LIS521",
                  method: "post",
                  data: {
                      action: "initoption",
                  },
              });
              if (res) {
                  this.hideinstrqcval = res.hideinstrqcval == "1" ? true : false;
                  this.hidelastuserndt = res.hidelastuserndt == "1" ? true : false;
              }
          } catch (e) {
              this.$message.warning(e);
          }
      },
      initialList() {
          //主表查询
          if (this.queryCheck() === false) return;
          this.resetData();
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS5/LIS521",
                  method: "post",
                  data: {
                      action: "query",
                      instrid: Number(this.instrId),
                      instridlist: this.instrId ? "" : this.instridlist,
                      qcdate1: this.qcdate1,
                      qcdate2: this.qcdate2,
                      qcitem: this.qcitem,
                      batchno: this.batchno,
                      qclevel: this.qclevel,
                      inuse: this.inuse,
                      draw: this.draw,
                      check: this.check,
                      contro: this.contro,
                      shownotmatch: this.shownotmatch,
                      showQcinstritem: this.showQcinstritem,
                  },
              })
              .then((response) => {
                  this.tableData1 = response.Data;
                  this.loading = false;
              })
              .catch((e) => {
                  this.loading = false;
              });
      },

      delDetail() {
          var tables = [];
          var selectRows = this.$refs.xTable1.getSelectRecords();
          if (selectRows) {
              for (let index in selectRows) {
                  tables.push(selectRows[index].qcdataid);
              }
          } else {
              return;
          }
          if (tables.length == 0) return;
          this.$confirm("你确定删除这些质控记录?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          }).then(() => {
              this.$tool
                  .request({
                      url: "LIS/LIS5/LIS521",
                      method: "post",
                      data: {
                          action: "delete",
                          tables: tables,
                      },
                  })
                  .then((response) => {
                      if (response.errcode == "1") {
                          this.initialList();
                          // this.$message({
                          //     message: "删除数据成功！",
                          //     type: "success",
                          // });
                      } else {
                          this.$message({
                              dangerouslyUseHTMLString: true,
                              message: "复制失败！<br/><br/>详细信息：" + response.errmsg,
                              type: "warning",
                          });
                      }
                  })
                  .catch((e) => {
                      console.log("error", e);
                  });
          });
      },
      //切换仪器时刷新界面
      labinstrumentchange(id, name) {
          this.instrId = id;
          this.instrname = name;
          if (Number(this.instrId) > 0) this.instridlist = "";
          this.$nextTick(() => {
              //this.initialList();
          });
      },

      //切换仪器时刷新界面
      labinstrlistchange(id, name) {
          this.instridlist = id;
          if (this.instridlist.length > 0) this.instrId = "";
          this.$nextTick(() => {
              //this.initialList();
          });
      },
      //定义 失控单元格颜色
      getOutcontrolClassname({ row, rowIndex, $rowIndex, column }) {
          if (column.property == "controlstatus") {
              if (row.controlstatus == "0") return "setoutcontrolcolor";
              if (row.controlstatus == null) return "setoutcontrolcolorNull";
          }
      },
      ///////////////////////////////////工具函数 /////////////////////////////////////////
      getDataByAjax(
          request,
          okMsg,
          errMsg,
          okFunction, // 取得数据后的回调函数
          errFunction // 获取数据失败后回调函数
      ) {
          this.$tool.request(request).then((response) => {
              if (response.errcode == "1") {
                  if (XEUtils.isString(okMsg)) {
                      if (XEUtils.getSize(XEUtils.trim(okMsg)) > 0) {
                          this.$message({
                              message: okMsg,
                              type: "success",
                          });
                      }
                  }
                  if (typeof okFunction == "function") okFunction(response.Data);
              } else {
                  this.$message({
                      dangerouslyUseHTMLString: true,
                      message: errMsg + "<br><br>详细信息：" + response.errmsg,
                      type: "warning",
                  });
                  if (typeof errFunction == "function") errFunction(response.Data);
              }
          });
      },

      insertRowAtLast(xtable, row) {
          xtable.insertAt(row, -1); //在最后添加一行
          var curow = xtable.getTableData().fullData[xtable.getTableData().fullData.length - 1]; //获取 新加的行对象 row 数据集合
          xtable.setCurrentRow(curow); //高亮显示行
          this.$nextTick(() => {
              xtable.scrollToRow(curow); //待数据加载完成后，延迟 滚动 到行
          });
      },

      //自动加载表格的第一行，并执行回调函数
      loadFirstRow(xTable, func) {
          this.$nextTick(() => {
              // 加载第一行
              var selectrow = xTable.getData(0);
              if (selectrow) {
                  xTable.setCurrentRow(selectrow); //高亮行
                  xTable.scrollToRow(selectrow); //滚动到行
                  if (typeof func == "function") func(selectrow);
              } else {
                  xTable.setCurrentRow(null); //这个不会自动清空
              }
          });
      },

      //自制必填校验函数，以后待扩展
      valid(obj, message) {
          if (XEUtils.isUndefined(obj)) {
              return this.$message({
                  message: message,
                  type: "warning",
              });
          }
          if (XEUtils.isNull(obj)) {
              return this.$message({
                  message: message,
                  type: "warning",
              });
          }
          if (XEUtils.isString(obj)) {
              if (!XEUtils.getSize(obj) > 0) {
                  return this.$message({
                      message: message,
                      type: "warning",
                  });
              }
          }
          if (XEUtils.isDate(obj)) {
              if (obj < XEUtils.toStringDate("2000-01-01")) {
                  return this.$message({
                      message: message,
                      type: "warning",
                  });
              }
          }
      },

      //删除表格行工具//TODO 连续 点删除按钮会有失去焦点的问题待解决
      deleteRow(xTable) {
          var delrow = xTable.getCurrentRow();
          this.DelIndex = xTable.getRowIndex(delrow);
          xTable.remove(delrow);
          if (this._this.DelIndex > -1 && xTable.tableData.length > 0) {
              if (xTable.getTableData().fullData.length > this.DelIndex) this.DelIndex = this.DelIndex;
              elsethis.DelIndex = this.DelIndex - 1;
              var selectrow = xTable.getTableData().fullData[this._this.DelIndex];
              this.$nextTick(() => {
                  xTable.setCurrentRow(selectrow);
              });
          } else {
              var nowdata = xTable.getTableData().fullData.filter((item) => {
                  return item._XID < delrow._XID;
              });
              if (nowdata.length > 0) {
                  var selectrow = nowdata[nowdata.length - 1];
                  this.$nextTick(() => {
                      xTable.setCurrentRow(selectrow);
                  });
              }
          }
      },

      stddevp(numbers) {
          var mean = 0;
          var sum = 0;
          var avgValue, sdValue, cvValue;
          for (var i = 0; i < numbers.length; i++) {
              sum += Number(numbers[i]);
          }
          mean = sum / numbers.length;
          avgValue = mean;

          sum = 0;
          for (var i = 0; i < numbers.length; i++) {
              sum += Math.pow(numbers[i] - mean, 2);
          }
          sdValue = Math.sqrt(sum / numbers.length);

          if (avgValue != 0) {
              cvValue = (sdValue * 100) / avgValue;
          } else {
              cvValue = null;
          }
          return {
              avgValue: XEUtils.toFixedString(mean, 2),
              sdValue: XEUtils.toFixedString(sdValue, 2),
              cvValue: XEUtils.toFixedString(cvValue, 2),
          };
      },
      FormatExport(cellValue, list) {
          let item = list.find((item) => item.value == cellValue);
          return item ? item.label : "";
      },
      qclevelChange(code, name) {
          this.qclevel = code;
          this.qclevelname = name;
      },
      qcitemChange(code, name) {
          this.qcitem = code;
          this.qcitemname = name;
      },
      BtnExporttxt(){
           if (this.$refs.xTable1.afterFullData.length > 0) {
              let filename = "LIS521质控数据查询";
              let filestr = "";
              var tableColumn = this.$refs.xTable1.getColumns();
              tableColumn.forEach((item) => {
                  if (item.title) filestr += item.title + "\t";
              });
              filestr += "\r\n";
              let exportData = XEUtils.clone(this.tableData1, true);
              exportData.forEach((e) => {
                  filestr += e.instrname + "\t";
                  filestr += e.qcdate + "\t";
                  filestr += e.itemcode_en + "\t";
                  filestr += e.rpt_itemname + "\t";
                  filestr += e.batchno + "\t";
                  filestr += e.qclevel + "\t";
                  filestr += e.resultdt + "\t";
                  filestr += e.displayvalue + "\t";
                  filestr += e.calculatevalue + "\t";
                  filestr += e.calculatesd + "\t";
                  filestr += e.cp_calculatecv + "\t";
                  filestr += e.controlstatus + "\t";
                  filestr += e.inuseflag + "\t";
                  filestr += e.drawflag + "\t";
                  filestr += e.checkflag + "\t";
                  filestr += e.begindt + "\t";
                  filestr += e.tagvalue + "\t";
                  filestr += e.sd + "\t";
                  filestr += e.cp_outcontroltips + "\t";
                  filestr += e.outcontrolreason + "\t";
                  filestr += e.outcontroloperation + "\t";
                  filestr += e.outcontrolresult + "\t";
                  filestr += e.cp_outcontroluser + "\t";
                  filestr += e.outcontroloperatedt + "\t";
                  filestr += e.checkdt + "\t";
                  filestr += e.cp_checkuser + "\t";
                  filestr += e.lastmodifydt + "\t";
                  filestr += e.cp_lastmodifyuser + "\t";
                  filestr += e.comments + "\t";
                  filestr += e.qcvaluesign + "\t";
                  filestr += e.qcname + "\t";
                  filestr += e.qcdataid + "\t";
                  filestr += e.qcitemvalueid + "\t";
                  filestr += e.qcid + "\r\n";
              });
              filestr = filestr.replace(/null/g, "");
              setTimeout(() => {
                  let p = { prgno: "LIS661", filename: filename, filestr: filestr };
                  this.$pub.commexport(this, p, filename + ".txt", "text/html;charset=gb2312");
              }, 1000);
          } else {
              this.$alert("请先查询出有效数据。", "提示", {
                  confirmButtonText: "确定",
                  type: "warning",
              });
              return false;
          }
      },
      BtnExport() {
          if (this.$refs.xTable1.afterFullData.length > 0) {
              let tableColumn = [];
              let extableColumn = [];
              //导出结果
              tableColumn = this.$refs.xTable1.getColumns();
              tableColumn.forEach((item) => {
                  extableColumn.push({ title: item.title, field: item.property });
              });
              let exportData = XEUtils.clone(this.tableData1, true);
              exportData.forEach((e) => {
                  e.controlstatus = this.controlstatusList.find((item) => item.value == e.controlstatus) ? this.controlstatusList.find((item) => item.value == e.controlstatus).label : "";
                  e.inuseflag = this.dgList.find((item) => item.value == e.inuseflag) ? this.dgList.find((item) => item.value == e.inuseflag).label : "";
                  e.drawflag = this.dgList.find((item) => item.value == e.drawflag) ? this.dgList.find((item) => item.value == e.drawflag).label : "";
                  e.checkflag = this.dgList.find((item) => item.value == e.checkflag) ? this.dgList.find((item) => item.value == e.checkflag).label : "";
              });
              // let filtertxt = this.getExportFilter();
              this.$pub.exportTableExcel(exportData, extableColumn, "LIS521 质控数据查询.xlsx");
          } else {
              this.$alert("请先查询出有效数据。", "提示", {
                  confirmButtonText: "确定",
                  type: "warning",
              });
              return false;
          }
      },
      // 获取当前导出文件的所有查询条件
      getExportFilter() {
          let filtertxt = "";
          let qcdttxt = "";
          if (this.qcdate1) qcdttxt += XEUtils.toDateString(this.qcdate1, "yyyy-MM-dd");
          if (this.qcdate2) qcdttxt += "至" + XEUtils.toDateString(this.qcdate2, "yyyy-MM-dd");
          if (qcdttxt) filtertxt += "质控日期:" + qcdttxt + "; ";
          if (this.instrId) filtertxt += "仪器:" + this.instrname + "; ";
          if (this.inuse) filtertxt += "累计:" + this.getOptionName(this.inuseOption.filter((item) => this.inuse == item.value)) + "; ";
          if (this.draw) filtertxt += "画图:" + this.getOptionName(this.drawOption.filter((item) => this.draw == item.value)) + "; ";
          if (this.instridlist) filtertxt += "仪器多选:" + this.instrsname + "; ";
          if (this.batchno) filtertxt += "批号:" + this.batchno + "; ";
          if (this.qclevel) filtertxt += "水平:" + this.qclevelname + "; ";
          if (this.qcitem) filtertxt += "质控项目:" + this.qcitemname + "; ";
          if (this.check) filtertxt += "审核:" + this.getOptionName(this.checkOption.filter((item) => this.check == item.value)) + "; ";
          filtertxt += "失控:" + this.getOptionName(this.controOption.filter((item) => this.contro == item.value)) + "; ";
          if (this.shownotmatch == "1") filtertxt += "仅显示不匹配数据; ";
          if (this.showQcinstritem == "1") filtertxt += "仅查询质控项目相关数据; ";
          return filtertxt;
      },
      getOptionName(option) {
          if (option && option.length > 0) {
              let optionname = "";
              option.forEach((item) => {
                  if (item.hasOwnProperty("label")) {
                      optionname += item.label + ",";
                  } else {
                      optionname += item.display + ",";
                  }
              });
              return optionname.substring(0, optionname.length - 1);
          } else {
              return "";
          }
      },
      //关闭按钮
      BtnExc() {
          let index = this.$parent.$refs.itemtags.tagsList.findIndex((m) => m.name == "LIS521");
          this.$parent.$refs.itemtags.tagsList.splice(index, 1);
          this.$router.go(-1);
      },
  },
  beforeRouteEnter(to, from, next) {
      next((vm) => {
          let that = vm;
          let altArr = [];
          document.onkeydown = function (e) {
              let key = window.event.keyCode;
              //*组合按键
              if (altArr.length > 0) {
                  //65到90 a到z（A到Z）
                  // //*Alt + C 清除
                  // if (key == 67) {
                  //     this.BtnExc();
                  // }
                  //*Alt + E 导出
                  if (key == 69) {
                      that.BtnExport();
                   }else if (key == 84) {
                      that.BtnExporttxt();
                  } else if (key == 88) {
                      //*Alt + X 退出
                      that.BtnExc();
                  }
              } else {
                  if (key == 119) {
                      //F8
                      that.initialList();
                  } else if (key == 114) {
                      //F3
                      that.delDetail();
                  } else if (key == 18) {
                      //按下了alt
                      altArr.push(key);
                  }
              }
          };
          document.onkeyup = function (e) {
              let key = window.event.keyCode;
              if (key == 18) {
                  altArr = [];
              }
          };
      });
  },
};
</script>

<style scoped>
.pagetop {
  left: 0;
  right: 0;
  height: 108px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
  text-align: left;
}
.pagebottom {
  width: 100%;
  height: 40px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: left;
  position: absolute;
  bottom: 0px;
  font-size: 12px;
  border: solid 1px #ccc;
}
.pagecenter {
  position: absolute;
  top: 112px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
.middle-center {
  position: absolute;
  height: 100%;
  right: 485px;
  left: 0;
}

.middle-right {
  position: absolute;
  top: 0;
  bottom: 2px;
  overflow: visible;
  width: 480px;
  right: 0px;
}

table tr td:nth-child(1) {
  width: 80px;
}
table {
  font-size: 12px;
}
::v-deep .setoutcontrolcolor {
  background-color: #ff6666 !important;
}
::v-deep .setoutcontrolcolorNull {
  background-color: #cccccc !important;
}
</style>
// table tr td:nth-child(odd) {
//     text-align: right;
//     white-space: nowrap;
// }
// table tr td:nth-child(even) {
//     text-align: left;
// }